﻿using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using YArchitech.LIB;

namespace HYBatchPrinter
{
	public partial class RenameViewSheetSetForm : System.Windows.Forms.Form
	{
		public RenameViewSheetSetForm(ViewSheets viewSheet)
		{
			this.InitializeComponent();
			this.m_viewSheet = viewSheet;
		}

		private void RenameViewSheetSetForm_Load(object sender, EventArgs e)
		{
			//base.Icon = Resource.YArchitechIcon;
			this.tbCurName.Text = this.m_viewSheet.SettingName;
		}

		public string GetNewSheetName()
		{
			return this.tbNewName.Text;
		}

		private bool HasSheetName(string sSheetName)
		{
			bool result = false;
			if (this.m_viewSheet.ViewSheetSetNames.Contains(sSheetName))
			{
				result = true;
			}
			return result;
		}

		private void btnOK_Click(object sender, EventArgs e)
		{
			string text = this.tbNewName.Text;
			if (string.IsNullOrEmpty(text) || string.IsNullOrWhiteSpace(text))
			{
				MessageBox.Show("图纸集名称不能为空，请重新输入。", "盈建科提示");
				this.tbNewName.Focus();
				this.tbNewName.Text = "";
				return;
			}
			if (this.HasSheetName(text))
			{
				MessageBox.Show("图纸集名称已存在，请重新输入。", "盈建科提示");
				this.tbNewName.Focus();
				this.tbNewName.SelectAll();
				return;
			}
			this.m_viewSheet.Rename(text);
			base.DialogResult = DialogResult.OK;
		}

		private ViewSheets m_viewSheet;
	}
}
